<?php

/**
 * @author 3picM1ke
 * @copyright 2009
 */

define( 'APP', true );

/**
 * Command = file
 */
$aCommands = array( );
$aCommands[ 'help' ] = 'help';
$aCommands[ '?' ] = 'help';
$aCommands[ 'blog' ] = 'blog';

if( !isset( $_POST[ 'cmd' ] ) )
{
    
    die( );
    
}

if( strlen( $_POST[ 'cmd' ] ) > 100 )
{
    
    echo 'Command too long';
    die();
    
}

$sInput = htmlentities( stripslashes( $_POST[ 'cmd' ] ) );
$aCmd = explode( ' ', $sInput );

$sCmd = array_shift( $aCmd );

$sString = implode( " ", $aCmd );

/**
 * Return command
 */
echo '[root@' . $_SERVER[ 'REMOTE_ADDR' ] . ' ~] '  . $sInput . "\n";

switch( $sCmd )
{
    
    default:
    {
        
        echo '-bash: ' . $sCmd . ': command not found';
        break;
        
    }
    
    case 'help':
    case '?':
    {
        
        echo 'Commands:' . "\n";
        echo '- help' . "\n";
        echo '- blog';
        break;
        
    }
    
    case 'blog':
    {
        
        if( empty( $sString ) )
        {
            
            /**
             * Blog List
             */
            
            echo 'Last 10 blogs:' . "\n";
            echo 'ID - Title' . "\n";
            echo '1 - Test blog' . "\n\n";
            echo 'To read a blog type: blog ID';
            
        }
        else
        {
            
            /**
             * Blog Item
             */
            
            if( $sString == 1 )
            {
                
                echo 'This is a test blog, sexy huh?';
                            
            }
            else
            {
                
                echo '-bash: ' . $sCmd . ' ' . $sString . ': blog not found';
                            
            }
            
        }
        
        break;
            
    }
    
    case 'geheimesexpagina':
    {
        
        echo '*bats*';
        break;
        
    }
                 
}

?>